import ajax from '@/utils/ajax.js'
import store from 'store'

// 查询商品列表及商品下的集合 只支持模糊查询和商品类型查询（加入了缓存的原因） 无分页
export const getCommodity = (data1) => {
	// console.log(data);
	return ajax({
		url: '/base/user/commodity/list',
		header: {
			authentication: store.getters.getUserInfo.token
		},
		data: {
			...data1,
			status: 1
		}
	})
}

// 获取单个商品信息
export const getCommodityInfo = (id) => {
	return ajax({
		url: `/base/user/commodity/${id}`,
		header: {
			authentication: store.getters.getUserInfo.token
		}
	})
}

// 获取团购列表
export const getBuy = () => {
	return ajax({
		url: '/base/user/buy/list',
		header: {
			authentication: store.getters.getUserInfo.token
		}
	})
}

// 获取团购信息
export const getBuyInfo = (id) => {
	return ajax({
		url: `/base/user/buy/detailed/${id}`,
		header: {
			authentication: store.getters.getUserInfo.token
		}
	})
}

// 新增团购
export const addBuy = (data) => {
	return ajax({
		url: `/base/user/buy`,
		header: {
			authentication: store.getters.getUserInfo.token
		},
		method: 'POST',
		data
	})
}

// 新增团购
export const isNoBuy = (buyNumber) => {
	return ajax({
		url: `/base/user/buy/isNoBuy`,
		header: {
			authentication: store.getters.getUserInfo.token
		},
		data: {
			number: buyNumber
		}
	})
}

// 关于我们
export const getConcerning = () => {
	return ajax({
		url: `/common/concerning`,
		header: {
			authentication: store.getters.getUserInfo.token
		}
	})
}

// 关于我们
export const setConcerning = (data) => {
	// console.log(1);
	return ajax({
		url: `/common/concerning`,
		header: {
			authentication: store.getters.getUserInfo.token
		},
		method: 'POST',
		data
	})
}
// setConcerning({
// 	concerning1: '1414141241421421'
// })

// 获取圈子列表
export const getCircleList = (data) => {
	return ajax({
		url: `/base/user/circle/list`,
		header: {
			authentication: store.getters.getUserInfo.token
		}
	})
}

// 发布圈子
export const issue = (data) => {
	return ajax({
		url: `/base/user/circle`,
		header: {
			authentication: store.getters.getUserInfo.token
		},
		method: 'POST',
		data
	})
}

// 圈子评论
export const issueComment = (data) => {
	return ajax({
		url: `/base/user/comment`,
		header: {
			authentication: store.getters.getUserInfo.token
		},
		method: 'POST',
		data
	})
}

// 圈子评论
export const updataLike = (data) => {
	return ajax({
		url: `/base/user/follow`,
		header: {
			authentication: store.getters.getUserInfo.token
		},
		method: 'POST',
		data
	})
}

// 删除圈子
export const delCircle = (ids) => {
	return ajax({
		url: `/base/user/circle/${ids}`,
		header: {
			authentication: store.getters.getUserInfo.token
		},
		method: 'DELETE'
	})
}

// 获取商品下的评价
export const goodsCommens = (id) => {
	return ajax({
		url: `/base/user/commen/list?commodityId=${id}`,
		header: {
			authentication: store.getters.getUserInfo.token
		}
	})
}